package tls;

public class ArrayUtils {

	/**
	 * Concatenate two arrays 
	 * @param arrA
	 * @param arrB
	 * @return Return the newly formed array
	 */
	public static byte [] concat(byte [] arrA, byte [] arrB){
		byte [] arrRet;		
		if(arrA == null){
			return arrB;
		}		
		if(arrB == null){
			return arrA;
		}
		
		arrRet = new byte[arrA.length +  arrB.length];
		
		System.arraycopy(arrA,0,arrRet,0,arrA.length);
		System.arraycopy(arrB, 0, arrRet, arrA.length, arrB.length);
		return arrRet;
	}
	
	public static byte [] xorArr(byte [] arrA, byte [] arrB){
		assert arrA.length == arrB.length;
		byte [] retArr = new byte[arrA.length];
		
		for(int byte_cnt = 0; byte_cnt < arrA.length; byte_cnt ++){
			retArr[byte_cnt] = (byte)(arrA[byte_cnt] ^ arrB[byte_cnt]);
		}
		
		return retArr;
	}
}
